//
//  LeftViewController.m
//  微blog
//
//  Created by Jorn.Wu on 15/8/25.
//  Copyright (c) 2015年 Jorn.Wu(jorn_wza@sina.com). All rights reserved.
//

#import "LeftViewController.h"
#import "MMExampleDrawerVisualStateManager.h"
#import "ThemeLabel.h"
#import "ThemeImageView.h"

@interface LeftViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, copy) NSArray *sectionTitles;
@property (nonatomic, copy) NSArray *rowTitles;

@end

@implementation LeftViewController

/**
 * 控制器的创建
 */
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        
        // 1.初始化数据
        [self loadData];
        
        // 2.初始化子视图
        [self initViews];
        
    }
    return self;
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // 1.初始化数据
        [self loadData];
        
        // 2.初始化子视图
        [self initViews];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
}






// 2.初始化子视图
- (void)initViews
{
    // 创建表视图
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 125, kScreenHeight) style:UITableViewStyleGrouped];
    _tableView.backgroundColor = [UIColor clearColor];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    // 设置内填充
    _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 150)];
    [self.view addSubview:_tableView];
}

// 1.初始化数据
- (void)loadData
{
    _sectionTitles = @[@"界面切换效果",@"图片浏览模式"];
    
    _rowTitles = @[@[@"无",
                     @"偏移",
                     @"偏移&缩放",
                     @"旋转",
                     @"视差"],
                   @[@"小图",
                     @"大图"]];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return _sectionTitles.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_rowTitles[section] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"leftCellId";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.backgroundColor = [UIColor clearColor];
    }
    
    
    cell.textLabel.text = _rowTitles[indexPath.section][indexPath.row];
    return cell;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    
    
    ThemeLabel *sectionLabel = [[ThemeLabel alloc] initWithFrame:CGRectMake(0, 0, 160, 50)];
    sectionLabel.textColorName = @"More_Item_Text_color";
    sectionLabel.backgroundColor = [UIColor clearColor];
    sectionLabel.font = [UIFont boldSystemFontOfSize:18];
    sectionLabel.text = [NSString stringWithFormat:@"  %@", _sectionTitles[section]];
    return sectionLabel;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 50;
}

@end
